<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ include file="/includes/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加用户</title>
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/common.css" type="text/css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.4.2.min.js"></script>
<script language="javascript" type="text/javascript" src="<%=request.getContextPath()%>/js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
	var type = '${type}';
	if(type=='add'){
		alert("课程添加成功！");
	}else if(type=='edit'){
		window.location.href = "listCourse.action";
	}
	
	function selTeacher(){
		var teacherId = "${course.teacher.id}";
		if(teacherId == ""){
			teacherId = $("#departmentId").val();			
		}
		var action = "listClazzJson.action?department.id="+teacherId;
		$.getJSON(action,function(data){
			var json = eval(data);
			$.each(json,function(i,n){
				if(clazzId==json[i].id){
					$("#clazz").append('<option selected value='+json[i].id+'>'+json[i].name+'</option>');
				}else{
					$("#clazz").append('<option value='+json[i].id+'>'+json[i].name+'</option>');
				}
			})
		})
	}
</script>
</head>
	<body>
		<div id="man_zone">
		<form action="saveCourse.action" method="post" id="form1" >
		<input type="hidden"  name="course.id" value="${course.id}"/>
		<input type="hidden"  name="course.version" value="${course.version}"/>
		 <table class="table_style" border="0" align="center"  cellpadding="3" cellspacing="1" width="800px">
		   	<tr>
		   		<td class="left_title_1">课程名称:</td>
		   		<td>
		   		<input type="text" id="course.name" name="course.name" value="${course.name}"/>
		   		<s:if test="hasFieldErrors() && fieldErrors.get('course.name') != null">
					<s:fielderror><s:param>course.name</s:param></s:fielderror>
				</s:if>
		   		</td>
		   		<td class="left_title_1">课程编号:</td>
		   		<td>
		   		<input type="text" id="course.code" name="course.code" value="${course.code}" <s:if test="course.id!=null">readOnly</s:if>/>
		   		<s:if test="hasFieldErrors() && fieldErrors.get('course.code') != null">
					<s:fielderror><s:param>course.code</s:param></s:fielderror>
				</s:if>
				<s:actionerror/>
		   		</td>
		   	</tr>
		   	<tr>
		   		<td class="left_title_1">学分:</td>
		   		<td>
		   		<input type="text" id="course.credit" name="course.credit" value="${course.credit}"/>
		   		<s:if test="hasFieldErrors() && fieldErrors.get('course.credit') != null">
					<s:fielderror><s:param>course.credit</s:param></s:fielderror>
				</s:if>
		   		</td>
		   		<td class="left_title_1">学期:</td>
		   		<td>
		   		<input type="text" id="course.term" name="course.term" value="${course.term}"/>
		   		<s:if test="hasFieldErrors() && fieldErrors.get('course.term') != null">
					<s:fielderror><s:param>course.term</s:param></s:fielderror>
				</s:if>
		   		</td>	
		   	</tr>
		   	<tr>
		   	   <td class="left_title_1">课程类型:</td>
		   		<td>
		   		<select id="course.status" name="course.status">
		   				<option value="">---课程类型---</option>
		   				<option value="1" <s:if test="1 == course.status">selected</s:if>>必选课</option>
		   				<option value="2" <s:if test="2 == course.status">selected</s:if>>限选课</option>
		   				<option value="3" <s:if test="3 == course.status">selected</s:if>>通选课</option>			
		   		</select>
		   			
		   		</td>
		   		<td class="left_title_1">教师:</td>
		   		<td>
		   			<select id="course.teacher.id" name="course.teacher.id" >
		   				<option value="">---请选择教师---</option>
		   					<s:iterator value="teachers" id="teacher" status="st">
		   					<option value="${id}" <s:if test="id == course.teacher.id">selected</s:if>>${name}</option>
		   				</s:iterator>
		   			</select>
		   			<s:if test="hasFieldErrors() && fieldErrors.get('course.teacher.id') != null">
					<s:fielderror><s:param>course.teacher.id</s:param></s:fielderror>
				    </s:if>
		   		</td>	
		   </tr>
		   
		<tr>
        </tr>
		  </table>
		  <table class="table_style" border="0" align="center"  cellpadding="3" cellspacing="0">
       		<tr>
         <td>
          <input type="submit" value="提交" />
          <span class="sub_sp">&nbsp;</span>
          <s:reset value="重置"/>  
         </td>
       </tr>
	</table>
		</form>
		</div>
	</body>
</html>